package dao

import javax.inject.{Inject, Singleton}
import models.Tables._
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.jdbc.JdbcProfile

import scala.concurrent.ExecutionContext.Implicits.global

/**
 * Created by yz on 2018/7/17
 */
@Singleton
class DetailBsDao @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends
  HasDatabaseConfigProvider[JdbcProfile] {

  import profile.api._

  def insertAll(rows: List[DetailBsRow]) = db.run(DetailBs ++= rows).map(_ => ())

  def selectAll(geneSymbols: List[String]) = db.run(DetailBs.filter(_.geneSymbol.
    inSetBind(geneSymbols)).result)

  def selectAll(geneSymbol: String) = db.run(DetailBs.
    filter(_.geneSymbol === geneSymbol).result)

  def select(junctionId: String) = db.run(DetailBs.
    filter(_.junctionId === junctionId).result.head)

  def deleteAll = db.run(DetailBs.delete).map(_ => ())


}
